package com.woniuxy.springaop1.service.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class MyAspect implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        beforeAdvice();
        //执行的是目标方法 和之前手写的 method.invoke差不多
        Object proceed = invocation.proceed();
        afterAdvice();
        //这里是返回的对象
        return proceed;
    }
    public void beforeAdvice(){
        System.out.println("MyAspect.beforeAdvice：方法执行之前……");
    }
    public void afterAdvice() {
        System.out.println("MyAspect.afterAdvice: 方法执行之后……");
    }
}
